package Core 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author Serg de Adelantado
	 */
	public class DragContainer extends Sprite 
	{
		private var FBitmap:Bitmap;
		private var FCanvas:BitmapData;
		private var FImage:ImageContainer;
		private var FImages:Vector.<ImageContainer>;
		
		public function DragContainer() 
		{	
			FBitmap = null;
			mouseEnabled = false;
			FImages = new Vector.<ImageContainer>;
		}
		
		public function set Image(AImage:ImageContainer):void
		{
			if (FBitmap) 
			{
				Clear();
			}
			FImage = AImage;
			if (FImage)
			{
				FImage.ShowTools = false;
				FCanvas = new BitmapData(AImage.width, AImage.height);
				FCanvas.draw(AImage);
				FBitmap = new Bitmap(FCanvas);
				FBitmap.alpha = 0.5;
				addChild(FBitmap);
				FImage.ShowTools = true;
			}
		}
		
		public function get Image():ImageContainer
		{
			return FImage;
		}
		
		public function get DragItem():Bitmap
		{
			return FBitmap;
		}
		
		private function Clear():void
		{
			FCanvas.dispose();
			removeChild(FBitmap);
			FBitmap = null;
		}
	}

}